package com.copa.l1290;

/**
 * @author copa
 * @createDate 2022-09-05 10:13
 * @function 乘2法（这个是我万万没想到的...）
 */
public class Test2 {

    public int getDecimalValue(ListNode head) {
        int result = 0;
        while (head != null) {
            result = result * 2 + head.val;
            head = head.next;
        }
        return result;
    }

    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        head.next = new ListNode(0);
        head.next.next = new ListNode(0);
        System.out.println(new Test2().getDecimalValue(head));
    }
}
